﻿using System;
using System.Text;

using FireBus.Contracts;
using FireBus.Web.Contracts;


namespace FireBus.Web.Extensions.Profile
{
	public class Extension :
		IRequestListener<RouteListRequest, RouteListResponse>,
		IRequestListener<HttpRequest, HttpResponse>
	{
		public RouteListResponse OnRequest(RouteListRequest request)
		{
			var routes =
				new[]
					{
						new Route(
							"GET",
							"/login.fb",
							"login")
					};
			return new RouteListResponse(routes);
		}

		public HttpResponse OnRequest(HttpRequest request)
		{
			if (request == null)
			{
				throw new ArgumentNullException("request");
			}
			Byte[] html = null;
			if (request.Action == "login")
			{
				html = Encoding.UTF8.GetBytes("This is login page");
			}
			if (html == null)
			{
				html = new Byte[0];
			}
			return new HttpResponse("text/html", html);
		}
	}
}
